package com.cndcare.msc;

import com.cndcare.msc.handler.HeartHandler;
import com.cndcare.msc.handler.NettyClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class ClientApplication implements EnvironmentAware {

    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }

    @Override
    public void setEnvironment(Environment environment) {
        HeartHandler.MAX_UN_REC_PONG_TIMES = Integer.parseInt(environment.getProperty("netty.client.max-un-rec-pong-times"));
        NettyClient.READER_IDLE_TIME_SECONDS = Integer.parseInt(environment.getProperty("netty.client.reader-idle-time-seconds"));
        NettyClient.WRITER_IDLE_TIME_SECONDS = Integer.parseInt(environment.getProperty("netty.client.writer-idle-time-seconds"));
        NettyClient.ALL_IDLE_TIME_SECONDS = Integer.parseInt(environment.getProperty("netty.client.all-idle-time-seconds"));
    }
}